﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace comm
{
    public class StringHelper
    {
        public static string LineSplit(string str)
        {
            var sb = new StringBuilder();
            bool lastU = true;
            bool last_ = false;
            foreach (var c in str)
            {
                if (c >= 'A' && c <= 'Z')
                {
                    sb.Append((!lastU && !last_ ? "_" : "") + c);
                    lastU = true;
                }
                else
                {
                    sb.Append(c);
                    lastU = false;
                }
                last_ = c == '_';
            }
            return sb.ToString();
        }
        public static string[] SplitText(string str, string txt)
        {
            var ss = new string[3];
            var of = str.ToLower().IndexOf(txt);
            if (of > 0)
            {
                ss[0] = str.Substring(0, of);
            }
            ss[1] = str.Substring(of, txt.Length);
            if (of + txt.Length < str.Length)
            {
                ss[2] = str.Substring(of + txt.Length, str.Length - (of + txt.Length));
            }
            return ss;
        }
    }
}
